<template>
  <div>
    <ul>
      <li v-for="(item, index) in str" :key="item">
        {{ item }}<button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      str: [1, 5, 3],
    };
  },
  methods: {
    fn() {
      this.str.push(Math.floor(Math.random() * 100));
    },
    del(a) {
      this.str.splice(a, 1);
    },
  },
};
</script>

<style>
</style>